package com.example.midushop.service.category.impl;

import com.example.midushop.entity.category.CategoryOne;
import com.example.midushop.entity.category.CategoryTwo;
import com.example.midushop.mapper.category.CategoryOneMapper;
import com.example.midushop.mapper.category.CategoryTwoMapper;
import com.example.midushop.service.category.CategoryOntService;
import com.example.midushop.service.category.CategoryTwoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 一级分类信息服务接口实现类
 */
@Service
public class CategoryTwoServiceImpl implements CategoryTwoService {
    @Autowired
    CategoryTwoMapper categoryTwoMapper;

    /**
     * 根据一级分类ID,查询所有二级分类（不传二级分类ID时默认查询所有）
     * @param CategoryOne_id
     * @param CategoryTwo_id
     * @return 返回List集合
     */
    @Override
    public List<CategoryTwo> findCategoryTwoAll(long CategoryOne_id, long CategoryTwo_id,String CategoryTwo_name) {
        return categoryTwoMapper.findCategoryTwoAll(CategoryOne_id,CategoryTwo_id,CategoryTwo_name);
    }

    /**
     * 根据一级分类ID,添加二级分类
     * @param CategoryOne_id 一级分类ID
     * @param CategoryTwo_name 二级分类名称
     * @param sort 排序
     * @param create_time  创建时间
     * @param update_time  更新时间
     * @return 返回受影响行数
     */
    @Override
    public int addCategoryTwo(long CategoryOne_id, String CategoryTwo_name, int sort, Date create_time, Date update_time) {
        return categoryTwoMapper.addCategoryTwo(CategoryOne_id,CategoryTwo_name,sort,create_time,update_time);
    }
}
